import request from '@/utils/request'

// 电费管理 保存开户设置
export function getElectricOpenAcount(payload) {
  const data = payload
  return request({
    url: 'api/v2/backend/device/watt_hour_meter/open_acount',
    method: 'post',
    data
  })
}

// 电表 开户 获取 合同 的价格
export function getContectPrice(stallId) {
  const data = {
    stallId
  }
  return request({
    url: 'api/v2/backend/market/contract/watt_water_price',
    method: 'post',
    data
  })
}

// 获取采集器列表
export function getCollectorList(collectorNo) {
  const data = {
    collectorNo
  }
  return request({
    url: 'api/v2/backend/device/collector/list',
    method: 'post',
    data
  })
}

// 获取电表列表
export function getElectricMeterList(searchName) {
  const data = {
    searchName
  }
  return request({
    url: 'api/v2/backend/device/watt_hour_meter/list',
    method: 'post',
    data
  })
}

// 获取水表
export function getWaterMeterList(searchName) {
  const data = {
    searchName
  }
  return request({
    url: 'api/v2/backend/device/water_meter/list',
    method: 'post',
    data
  })
}

// 获取供应商列表
export function getSupplierList() {
  return request({
    url: 'api/v2/backend/device/supplier',
    method: 'post'
  })
}

// 保存采集器
export function saveCollector(payload) {
  const data = payload
  return request({
    url: 'api/v2/backend/device/collector/add',
    method: 'post',
    data
  })
}

// 删除采集器
export function removeCollector(id) {
  const data = {
    id
  }
  return request({
    url: 'api/v2/backend/device/collector/del',
    method: 'post',
    data
  })
}

// 保存电表
export function saveElectricMeter(payload) {
  const data = payload
  return request({
    url: 'api/v2/backend/device/watt_hour_meter/add',
    method: 'post',
    data
  })
}

// 删除电表
export function removeElectricMeter(id) {
  const data = {
    id
  }
  return request({
    url: 'api/v2/backend/device/watt_hour_meter/del',
    method: 'post',
    data
  })
}

// 获取采集器列表
export function getCollectorNoList() {
  return request({
    url: 'api/v2/backend/device/collector/select',
    method: 'post'
  })
}

// 保存水表
export function saveWaterMeter(payload) {
  const data = payload
  return request({
    url: 'api/v2/backend/device/water_meter/add',
    method: 'post',
    data
  })
}

// 删除水表
export function removeWaterMeter(id) {
  const data = {
    id
  }
  return request({
    url: 'api/v2/backend/device/water_meter/del',
    method: 'post',
    data
  })
}

// 清零 水表
export function resetWater(id) {
  const data = {
    id
  }
  return request({
    url: 'api/v2/backend/device/water_meter/reset',
    method: 'post',
    data
  })
}

// 清零 电表
export function resetElectric(id) {
  const data = {
    id
  }
  return request({
    url: 'api/v2/backend/device/watt_hour_meter/reset',
    method: 'post',
    data
  })
}

// 抄电表
export function readElectricMeter(id) {
  const data = {
    id
  }
  return request({
    url: 'api/v2/backend/device/watt_hour_meter/read',
    method: 'post',
    data
  })
}

// 电表 开关阀
export function pullElectricMeter(id, controlStatus) {
  const data = {
    id, controlStatus
  }
  return request({
    url: 'api/v2/backend/device/watt_hour_meter/pull_close',
    method: 'post',
    data
  })
}

// 抄水表
export function readWaterMeter(id) {
  const data = {
    id
  }
  return request({
    url: 'api/v2/backend/device/water_meter/read',
    method: 'post',
    data
  })
}

// 水表 开关阀
export function pullWaterMeter(id, controlStatus) {
  const data = {
    id, controlStatus
  }
  return request({
    url: 'api/v2/backend/device/water_meter/pull_close',
    method: 'post',
    data
  })
}
